package dongtai;

public class siyisan {
    public static int numberOfArithmeticSlices(int[] nums) {
        int n=nums.length;
        if(n<3){
            return 0;
        }
        int[] f=new int[n];
        f[0]=f[1]=0;
        int sum=0;
        for(int i=2;i<n;i++){
            f[i]=(nums[i]-nums[i-1]==nums[i-1]-nums[i-2])?(f[i-1]+1):0;
            sum+=f[i];
        }
        return sum;
    }

    public static void main(String[] args) {
        int[] nums={1,2,3,4};
        int i = numberOfArithmeticSlices(nums);
        System.out.println(i);

    }
}
